<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<h1>JavaScript Example 15</h1>
<br>
Working with Prototypes (classes).
<br>
<hr>
<br>

<!-- SCRIPT STARTS HERE -->

<script type="text/javascript">
	// define custom constructor
	function Student(firstName,name) {
		// initialize variables
		this.firstName = firstName;
		this.name = name;
		// initialize member function - use global variable
		// to make sure this is done only once
		if (typeof(_Student_initialized)=="undefined") {
			var _Student_initialized = true;
			// initialize member function
			Student.prototype.getFullName = getFullName; 
		}
		// define method (nested function)
		function getFullName() {
			return this.firstName + " " + this.name;
		}
	}	
	
	// use the new class
	var student = new Student("John","Smith");
	document.write(student.getFullName());
	
	
</script>


<!-- SCRIPT ENDS HERE -->

</body>
</html>
